Claude 原生接口调用
POST /v1/messages
Body 请求参数
{
  "model": "claude-3-5-sonnet-20241022",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "What is the meaning of life?"
    }
  ]
}
请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 | 
|---|---|---|---|---|
| x-api-key | header | string | 否 | Bearer AIHUBMIX_API_KEY | 
| Content-Type | header | string | 否 | none | 
| body | body | object | 否 | none | 
| » model | body | string | 是 | none | 
| » messages | body | [object] | 是 | none | 
| »» role | body | string | 否 | none | 
| »» content | body | string | 是 | none | 
| » max_tokens | body | number | 是 | none | 
返回示例
200 Response
{
  "id": "msg_013Uf6CwwyjSe35n3yVaPbLM",
  "type": "message",
  "role": "assistant",
  "model": "claude-3-5-sonnet-20241022",
  "content": [
    {
      "type": "text",
      "text": "That's one of humanity's most enduring and complex philosophical questions! While there's no universal answer, I aim to explore such questions thoughtfully while acknowledging their complexity. I try to focus on having meaningful conversations and helping where I can. What does meaning in life mean to you?"
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 14,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "output_tokens": 61
  }
}
返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 | 
|---|---|---|---|
| 200 | OK | none | Inline |